<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../commons/commons.jsp"%>
<!DOCTYPE html>
	<head>
		<meta charset="utf-8" />
		<title>后台</title>
		<script src="${ctx }/static/js/crud.js"></script>
	</head>

	<body>
	<form action="${ctx }/orderpay/list.do" id="submit-form">
	<div class="page-body">
		<div class="row">
			<div class="col-xs-12 col-md-12">
				<div class="widget">
					<div class="widget-header ">
						<span class="widget-caption">订单收费管理</span>
					</div>
					<div class="widget-body">
                        <div class="controls">
                             <div class="input-group">
								<input class="form-control" style="width:200px;margin-right: 5px;"  name="orderCode" value="${bean.orderCode }">
									
								<button type="submit" class="btn btn-default" style="height:34px" onClick="search()">搜索</button>
                             </div>
                    	</div>
                    </div>
						<table class="table table-striped table-bordered table-hover"
							id="simpledatatable" style="text-align:center;">
							<thead>
								<tr>
									<th>序号</th>
									<th>订单编号</th>
									<th>服务内容</th>
									<th>联系人</th>
									<th>联系方式</th>
									<th>服务开始时间</th>
									<th>服务周期</th>
									<th>金额</th>
									<th>状态</th>
									<th>收费状态</th>
									<th>收费操作</th>
								</tr>
							</thead>
							<tbody>
								 <c:forEach items="${pagination.rows }" var="item" varStatus="status">
                                      <tr>
                                          <td>${status.count}</td>
                                          <td>${item.orderCode }</td>
                                          <td class="orderToservice">
                                          	<c:forEach items="${servicelist }" var="serviceitem1">
                                          		<c:if test="${serviceitem1.id==item.serviceId}">
                                          			${serviceitem1.serviceName}服务
                                          		</c:if>
                                          	</c:forEach>
                                          </td>
                                          <td>${item.contacts }</td>
                                          <td>${item.contactMethod }</td>
                                          <td><fmt:formatDate value="${item.serviceTime }" pattern="yyyy-MM-dd" /></td>
                                          <td>${item.serviceCycle }个月</td>
                                          <td>￥${item.cost }</td>
										  <td>
										  	<c:if test="${item.arrange=='1'}">
												已安排
										  	</c:if>
										  	<c:if test="${item.arrange=='0'}">
												待安排
										  	</c:if>
										  </td>
										  <td>
										  	<c:if test="${item.pay=='1'}">
												已收费
										  	</c:if>
										  	<c:if test="${item.pay=='0'}">
												待收费
										  	</c:if>
										  </td>
										  <td>
										  	 <c:if test="${item.pay=='1'}">
												<a href="#" class="btn btn-info btn-xs edit" disabled><i class="fa fa-edit"></i>已收费</a>
										  	</c:if>
										  	<c:if test="${item.pay=='0'}">
										  		<c:if test="${item.arrange=='1'}">
										  			<a href="javascript:void(0)" class="btn btn-danger btn-xs delete" onclick="surepay('${item.id}')"><i class="fa fa-trash-o"></i>确定收费</a>
										  		</c:if>
										  		<c:if test="${item.arrange=='0'}">
													<a href="#" class="btn btn-info btn-xs edit" disabled><i class="fa fa-edit"></i>请先安排预约</a>
										  		</c:if>
										  	</c:if>
                                          </td>
                                      </tr>
                                </c:forEach>
							</tbody>
						</table>
						<%@include file="../commons/page.jsp"%>
					</div>
				</div>
			</div>
		</div>
	</form>
</body>
<script type="text/javascript">
	var length=$(".orderToservice").length;
	for(var i=0;i<length;i++){
		if($.trim($(".orderToservice ").eq(i).html())==""){
			$(".orderToservice ").eq(i).html("<p style='color:red'>该类服务已经下架</p>");
		}
	}

	function surepay(id){
			bootbox.confirm("你确定该预约收费到账吗？确定收费后将无法再次修改", function(result) {
				if(result){
					var url = '${ctx }' + "/orderpay/surepay.do";
				var sendData = {
					"oid" : id
				};
				$.get(url, sendData, function(backData) {
					if (backData.status == 1) {
						bootbox.confirm("操作成功", function(result) {
							if(result){
								window.location.href="${ctx }/orderpay/list.do";
							}
						})
					} else {
						warningAlert(backData.message[0].msg);
					}
				});
				}
			});
        }
</script>
</html>